<?php
/*------------------------------------------------------------------------
 * Banner管理
 * 	
 * Created on 2015-07-10
 *
 * Author: hwc123 <hwc123@139.com>
 * 
 * Copyright (c) 2014 http://www.suncco.com All rights reserved.
 * ------------------------------------------------------------------------
 */

namespace Admin\Controller;
class BannerController extends CommonController{
	public $exec_comfunc  = 'index,add,edit,del,delete,recycle';//index,add,edit,delete
	
	public function _initialize(){
		parent::_initialize();
		$type = $this->_get('type');
		$this->_jump_url = U('index', array('type' => $type));
	}
	
	public function index(){
		$type = $this->_get('type');
		if($type){
			$where['type'] = $type;
		}
		$this->assign('type',$type);

		$category_id = $this->_get('category_id');
		if($category_id){
			$where['category_id'] = $category_id;
		}
		$info['category_id'] = $category_id;

		//省份
		$province_id = $this->_get('province_id');
		$info['province_id'] = $province_id;
		if($province_id && !$city_id){
			$where['province_id'] = $province_id;
		}
		//城市
		$city_id = $this->_get('city_id');
		$info['city_id'] = $city_id;
		if($city_id){
			$where['city_id'] = $city_id;
		}
		$this->assign('info', $info);
		//客服城市
		if($this->_city_id){
			$where['city_id'] = array(array('eq',$this->_city_id),array('eq',0),'or');
		}
		if(!D('Role')->is_acl('show_category_field?type=' . $type)){
			$order['category_id'] = 'asc';
			$order['order_id']    = 'asc';
			$order['id']          = 'desc';
		}
		
		$where['is_delete'] = 0;
		$this->_boolean_field = array('no');
		$list = parent::index('', $where, $order);
	}
	public function recycle(){
		$where['type'] = $this->_get('type');
		parent::recycle('', $where);
	}
}
